@layout("/common/_curd/_container.html"){

	<form data-url="${basePath}/${code}/save" method="post" class="form-horizontal" role="form">
		@ var _table="tb_member_document";
		@ var _col=[
		@			  {name:"空白手册名称", index:"name",  type:"text",newline:true,length:8,required:"required"},
		@			  {name:"创建时间", index:"createTime",type:"laydate",value:func.getTime(),newline:true,length:8,required:"required"},
		@			  {name:"修改时间", index:"modifyTime", type:"laydate",value:func.getTime(),newline:true,length:8,required:"required"},
		@			  {name:"排序号", index:"order",value:"0", type:"number",newline:true,length:8,required:"required"},
		@			  {name:"空白模板手册路径", index:"path", type:"fileupload",newline:true,length:8,required:"required"},		
		@			  {name:"使用客户", index:"member_id", type:"hidden",newline:true,length:8,required:"required"},	
		@			  {name:"所属银行", index:"bank_id", type:"select_910",newline:true,length:8,required:"required"},			
		@			  {name:"银行业务", index:"bussiness_id", type:"hidden",newline:true,length:8,required:"required"}		
		@		   ];
		@ include("/common/_curd/_add.html", {"col":_col, "table":_table}){}
		
		<div class="form-group form-bussiness" style="display: block">
			<label class="col-sm-2 control-label no-padding-right">银行业务 </label>
			<div class="col-sm-8">
				<select
					class="form-control" id="bussiness_id">
					<option value=""></option>
				</select>
			</div>
		</div>
		
		<div class="form-group form-member" style="display: block">
			<label class="col-sm-2 control-label no-padding-right">使用客户 </label>
			<div class="col-sm-8">
				<select
					class="form-control" id="member_id">
					<option value=""></option>
				</select>
			</div>
		</div>
		
		<!-- 按钮 -->
		@ include("/common/_curd/_btn.html", {btn_save:"新增", btn_close:"关闭"}) {}
	</form>
<script type="text/javascript">
	
	$(function() {
		//任务下拉框联动  
		$(".form-area").insertAfter($("#_bank_id").parent().parent());
		function changeBank(){
			var selectReq = $("#_bank_id").val();
			if(selectReq == "") return;
			$.ajax({
				url: "/template/getBussinessList/" + selectReq,
				type: "post",
				dataType: "json", // 接受数据格式   
				error: function() {
					alert("请求失败!");
				},
				success: function(data) {
					var str = "";
					if(data != null && data != "") {
						str += "<option value=''>请选择</option>";
						for(var i = 0; i < data.length; i++) {
							str += "<option value='" + data[i].id + "'>" + data[i].name + "</option>";
						}
					}
					$("#bussiness_id").html(str);
				}
			});
		}
		$("#_bank_id").bind("change", function() {
			changeBank();
		});
		
		$("#bussiness_id").bind("change", function() {
			$("#_bussiness_id").val($('#bussiness_id').val());
			showPlaceHolder($("#_bank_id").val(), $("#bussiness_id").val());
		}); 
		
		/* function _bussiness_id_selectChanged(sid) {
			$("#_bussiness_id").val($('#' + sid).val());
			debugger
			showPlaceHolder($("#_bank_id").val(), $("#_bussiness_id").val());
		}; */
	 	function showPlaceHolder(bank_id,bussiness_id){
	 		$.ajax({
				url: "/baseDocument/getTemplateAttrList",
				data:{
					"bank_id":bank_id,
					"bussiness_id":bussiness_id
				},
				type: "post",
				dataType: "json", // 接受数据格式   
				error: function() {
					alert("请求失败!");
				},
				success: function(data) {
					if(data != null && data != "") {
						var str = "";
						for(var i = 0; i < data.length; i++) {
							str += "<a value='" + data[i].id + "' data-ename='"+data[i].ename+"' data-cname='"+data[i].cname+"' draggable='true' ondragstart='drag(event)'>" + data[i].cname+"("+data[i].ename+")" + "</a>";
						}	
					}
					$("#placeholder_ul").html(str);
				}
			});
	 	}
		
		changeMember();
		 $("#member_id").bind("change", function() {
				$("#_member_id").val($('#member_id').val());
		}); 
		function changeMember(){
			//var selectReq = $("#_member_id").val();
			//if(selectReq == "") return;
			$.ajax({
				url: "/member/getMemberList", //+ selectReq,
				type: "post",
				dataType: "json", // 接受数据格式   
				error: function() {
					alert("请求失败!");
				},
				success: function(data) {
					var str = "";
					if(data != null && data != "") {
						str += "<option value=''>请选择</option>";
						for(var i = 0; i < data.length; i++) {
							str += "<option value='" + data[i].id + "'>" + data[i].name + "</option>";
						}
					}
					$("#member_id").html(str);
				}
			});
		}
	
	})

	</script> 
@}